<?php

/**
 * WeEngine Api System
 *
 * (c) We7Team 2019 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace W7\Sdk\VSCode\Tests;

use W7\Sdk\VSCode\Traits\FileTrait;
use W7\Sdk\VSCode\Traits\StorageTrait;

/**
 * test copy
 */
class TestFileCopy extends TestCase {
	use StorageTrait, FileTrait;

	/**
	 * @var string
	 */
	private $content = 'hello123456';
	/**
	 * @var string
	 */
	private $route = '';
	/**
	 * @var string
	 */
	private $txtFrom = 'from.txt';
	/**
	 * @var string
	 */
	private $txtTo = 'to.txt';

	protected function setUp(): void {
		parent::setUp(); // TODO: Change the autogenerated stub
		$this->route = route('vs.code.copy');
	}

	/**
	 * test copy file
	 */
	public function testFileCopy() {
		$this->storageDeleteFile($this->txtFrom);
		$this->storageDeleteFile($this->txtTo);

		$this->storagePutContent($this->txtFrom, $this->content);
		$this->patchJson($this->route, ['uri' => $this->txtFrom, 'newuri' => $this->txtTo])->assertOk();
		$content = $this->storageGetContent($this->txtTo);
		$this->assertEquals($this->content, $content);
	}
}
